import  qrcode

class Make_Qr:
    # init
    def __init__(self, version = 15, error_level = 'Q', data = ''):
        self.version = version
        self.error_level = error_level
        self.data = data

    #
    def obj_qr(self):
        if self.error_level == 'H':
            return qrcode.QRCode(version=self.version, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=10, border=4)
        elif self.error_level == 'M':
            return qrcode.QRCode(version=self.version, error_correction=qrcode.constants.ERROR_CORRECT_M, box_size=10, border=4)
        elif self.error_level == 'L':
            return qrcode.QRCode(version=self.version, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
        elif self.error_level == 'Q':
            return qrcode.QRCode(version=self.version, error_correction=qrcode.constants.ERROR_CORRECT_Q, box_size=10, border=4)
        else:
            return 'nothing'
         
    # 
    def build_qr(self):     
        vers = self.version
        err_l = self.error_level

        qr = self.obj_qr()
        qr.add_data(self.data)
        qr.make(fit = True)

        img = qr.make_image()
        img.show()
        img.save('./qr_img.png')
        
    
    
    
    
if __name__ == '__main__':
    qrs = Make_Qr(10,'H','hello,world')
    qrs.build_qr()



